'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 摧毁城堡
 * @author sundbcn@gmail.com (sun debing)
 */

var _ = require('lodash');
var buildTypeUtil = require('../../util/buildTypeUtil');
var buildType = require('../../consts/buildType');

var CopyCondition = function () {

};

/**
 * 验证
 */
CopyCondition.prototype.getProgress = function (condition, record, damage_build_list, data) {
    var is_destroy_nexus = false;
    _.some(damage_build_list, function (damage_build) {
        // 判断是否是主城,如果主城未被打完,只算0星
        if (buildTypeUtil.getBuildType(damage_build.build_id) == buildType.WALL &&
            damage_build.hp === 0) {
            is_destroy_nexus = true;
            return true;
        }
    });

    return {
        progress: 0,
        total_progress: 0,
        is_pass: Number(is_destroy_nexus)
    };
};

module.exports = new CopyCondition();
